--- redirect_from: - "/04plotly/plotly" interact_link: content/04Plotly/plotly.ipynb kernel_name: python3 kernel_path: content/04Plotly has_widgets: false title: |- Plotly Figures pagenum: 3 prev_page: url: /03Demo_Code/demo.html next_page: url: suffix: .ipynb search: comment: "***PROGRAMMATICALLY GENERATED, DO NOT EDIT. SEE ORIGINAL FILES IN /content***" ---
Plotly Figures
import numpy as np
import plotly.graph_objects as go
import plotly.tools as tls
from plotly.offline import plot, iplot, init_notebook_mode
from IPython.core.display import display, HTML
init_notebook_mode(connected = True)
config={'showLink': False, 'displayModeBar': False}
G3_old = np.load('old.npy')
G3 = np.load('new.npy')
x = np.arange(29)
fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=G3_old[0],
                    mode='lines',
                    ))
fig.add_trace(go.Scatter(x=x, y=G3_old[1],
                    mode='lines',
                    ))
fig.add_trace(go.Scatter(x=x, y=G3_old[2],
                    mode='lines',
                     ))


#Binder and ThebeLab
plot(fig, filename = 'fig.html', config = config)

#ThebeLab
display(HTML('fig.html'))
#Binder
#plot(fig,config=config)
fig2 = go.Figure()
fig2.add_trace(go.Scatter(x=x, y=G3[0],
                    mode='lines',
                    ))
fig2.add_trace(go.Scatter(x=x, y=G3[1],
                    mode='lines',
                    ))
fig2.add_trace(go.Scatter(x=x, y=G3[2],
                    mode='lines',
                     ))


#Binder and ThebeLab
plot(fig2, filename = 'fig2.html', config = config)

#ThebeLab
display(HTML('fig2.html'))
#Binder
#plot(fig2,config=config)
fig3 = go.Figure()
fig3.add_trace(go.Scatter(x=x, y=G3_old[0],
                    mode='lines',
                    name = 'Line 1 before'
                    ))
fig3.add_trace(go.Scatter(x=x, y=G3[0],
                    mode='lines',
                    name = 'Line 1 after'
                    ))
fig3.add_trace(go.Scatter(x=x, y=G3_old[1],
                    mode='lines',
                     name = 'Line 2 before'
                    ))
fig3.add_trace(go.Scatter(x=x, y=G3[1],
                    mode='lines',
                     name = 'Line 2 after'
                    ))
fig3.add_trace(go.Scatter(x=x, y=G3_old[2],
                    mode='lines',
                    name = 'Line 2 before'
                     ))
fig3.add_trace(go.Scatter(x=x, y=G3[2],
                    mode='lines',
                     name = 'Line 3 after'
                     ))

fig3.update_layout(
    updatemenus=[
        dict(
            active=0,
            buttons=list([
                 dict(label="Show All",
                     method="update",
                     args=[{"visible": [True, True, True, True, True, True]},
                           {"title": "Before and After Comparation"}]),
                dict(label="Line 1",
                     method="update",
                     args=[{"visible": [True, True, False, False, False, False]},
                           {"title": "Line 1 comparation"}]),
                dict(label="Line 2",
                     method="update",
                     args=[{"visible": [False, False, True, True, False, False]},
                           {"title": "Line 2 comparation"
                            }]),
                dict(label="Line 3",
                     method="update",
                     args=[{"visible": [False, False,False,False, True, True]},
                           {"title": "Line 3 comparation"}]),
               
            ]),
        )
    ])
fig3.update_layout(title_text="Before and After Comparation")


#Binder and ThebeLab
plot(fig3, filename = 'fig3.html', config = config)

#ThebeLab
display(HTML('fig3.html'))
#Binder
# iplot(fig3,config=config)